import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import AutoImport from 'unplugin-auto-import/vite';
// https://vitejs.dev/config/

// const proxyUrl = "http://172.16.107.32:8888/";
// const proxyUrl = "https://pms.lingzhuyunpms.com/";
// const proxyUrl = "https://pms.lingzhuyunpms.cn/";
// const proxyUrl = "http://172.16.107.22/";
// const proxyUrl = "http://172.16.107.99/";

export default defineConfig({
    plugins: [
        vue(),
        Components({
            resolvers: [
                AntDesignVueResolver({
                    importStyle: false, // css in js
                }),
            ],
            dirs: ['src/components'],
            extensions: ['vue'],
            dts: 'src/components.d.ts',
        }),
        AutoImport({
            imports: ['vue', 'vue-router'],
            // 可以选择auto-import.d.ts生成的位置，使用ts建议设置为'src/auto-import.d.ts'
            dts: 'src/auto-import.d.ts',
            eslintrc: {
                enabled: true,
                filepath: './.eslintrc-auto-import.json',
                globalsPropValue: true,
            },
        }),
    ],
    resolve: {
        alias: {
            '@': '/src',
        },
    },
    server: {
        proxy: {
            '/api': {
                // target: proxyUrl,
                // target: 'https://pms.lingzhuyunpms.cn/',
                // target: 'http://172.16.0.144:7077',
                // target: 'http://172.16.0.66:8080',
                // target: 'http://172.16.1.17:8080',
                target: 'http://127.0.0.1:8080',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
            '/get_analysis_history': {
                target: 'http://127.0.0.1:4523/m1/5744320-5427094-default',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
            '/get_analysis_realtime': {
                target: 'http://127.0.0.1:4523/m1/5744320-5427094-default',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
            '/get': {
                target: 'http://127.0.0.1:8080',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
        },
        cors: true,
    },
});
